package com.study.spring.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

import java.util.Arrays;

public class DebugLog {

    public Object doLog(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        MethodSignature methodSignature  = (MethodSignature) proceedingJoinPoint.getSignature();

        String className = proceedingJoinPoint.getTarget().getClass().getSimpleName();
        String methodName = methodSignature.getMethod().getName();
        System.out.println(className + "." + methodName + ",请求参数" + Arrays.toString(proceedingJoinPoint.getArgs()));
        Object result = null;

        result = proceedingJoinPoint.proceed();
        System.out.println(className + "." + methodName + "调用结果" + result);
        return result;
    }

}
